package com.xiumiing.net;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.LifecycleOwner;

import android.os.Bundle;

import com.xiumiing.net.base.net.Api;
import com.xiumiing.net.base.net.observer.NetObserver;
import com.xiumiing.net.base.uitls.RxManager;
import com.xiumiing.net.bean.SchoolBean;

import java.util.List;

import io.reactivex.disposables.Disposable;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }

    private void test() {
        Api.getSchoolService().requestOpenSchools()
//                .retryWhen(new RetryWithDelay(3,2))
                .doOnSubscribe(this::addDisposable)
                .subscribe(new NetObserver<List<SchoolBean>>(){
                    @Override
                    public void onSuccess(List<SchoolBean> schoolBeans) {

                    }
                });
    }


    public RxManager mRxManager = new RxManager();

    protected void addDisposable(Disposable disposable) {
        if (null != mRxManager) {
            mRxManager.add(disposable);
        }
    }

    @Override
    protected void onDestroy() {
        if (mRxManager!=null){
            mRxManager.clear();
            mRxManager = null;
        }
        super.onDestroy();
    }
}
